<!-- 安全协议保障 -->
<template>
	<view>
		<view class="boxlv">
			<view style="height: 30rpx;"></view>
			<view class="m-card m-mg-lr u-p-t-40 u-p-b-50">
				<renzheng :zhuangtai="renzheng" :obj="menu[0]"></renzheng>
				<renzheng :zhuangtai="queren" :obj="menu[1]" @dianji="getdianji"></renzheng>
				<view class="u-m-t-40 u-flex u-flex-center" @click="requestStatus ? sumit() : ''"><view class="boxbutt">提交审核</view></view>
			</view>
		</view>
		<u-popup :show="show" @close="show = false" mode="top" bgColor="transparent" round="10" :customStyle="{ top: '30rpx' }">
			<view class="m-mg-lr m-card boxding">
				<!-- <u--form labelPosition="left" :borderBottom="false" :model="xieyi" ref="form1" labelWidth="100" :labelStyle="{ fontSize: '24rpx', color: '#5a5a5a' }">
					<u-form-item :label="type === 1 ? '甲方(出租方)' : '甲方(卖方)'" ref="item1">
						<u-search
							shape="square"
							searchIcon=" "
							disabled
							:clearabled="false"
							height="64"
							:showAction="false"
							v-model="reality_name"
							inputAlign="right"
							bgColor="#eee"
							placeholder=" "
						></u-search>
					</u-form-item>
					<u-form-item label="乙方(经纪方)" ref="item1">
						<u-search
							shape="square"
							searchIcon=" "
							disabled
							:clearabled="false"
							height="64"
							:showAction="false"
							v-model="xieyi.broker"
							inputAlign="right"
							bgColor="#eee"
							placeholder=" "
						></u-search>
					</u-form-item>
				</u--form> -->
				<view class="">
					<view class="c5a widtext u-font-36 m-font-b u-p-t-20">免责声明</view>
					<u-parse :content="type === 1 ? xieyi.leasecontract : xieyi.towhousecontract"></u-parse>
				</view>
				<!-- <u--form labelPosition="left" :borderBottom="false" :model="xieyi" ref="form1" labelWidth="100" :labelStyle="{ fontSize: '24rpx', color: '#5a5a5a' }">
					<u-form-item :label="type === 1 ? '甲方(出租方)' : '甲方(卖方)'" ref="item1">
						<u-search
							shape="square"
							searchIcon=" "
							disabled
							:clearabled="false"
							height="64"
							:showAction="false"
							v-model="reality_name"
							inputAlign="right"
							bgColor="#eee"
							placeholder=" "
						></u-search>
					</u-form-item>
					<u-form-item label="乙方(经纪方)" ref="item1">
						<u-search
							shape="square"
							searchIcon=" "
							disabled
							:clearabled="false"
							height="64"
							:showAction="false"
							v-model="xieyi.broker"
							inputAlign="right"
							bgColor="#eee"
							placeholder=" "
						></u-search>
					</u-form-item>
				</u--form> -->
				<view class="u-m-t-30 u-flex u-flex-items-center">
					<checkbox-group @change="checkboxChange">
						<label><checkbox :value="label.name" :checked="label.checked" color="#0e5642" style="transform:scale(0.7)" /></label>
					</checkbox-group>
					<view>{{ label.name }}</view>
				</view>
				<view class="u-m-t-30 u-flex boxali u-flex-center">
					<view class="boxque" :class="!label.checked ? '' : 'boxquelv'" @click="label.checked ? getclick() : ''">确认提交</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			xieyi: {},
			show: false,
			menu: [
				{
					img: 'https://neidangjia.oss-accelerate.aliyuncs.com/handhousing/img1.png',
					imgOn: 'https://neidangjia.oss-accelerate.aliyuncs.com/handhousing/img1_on.png',
					name: '实名认证',
					type: '去认证',
					typeOn: '已认证',
					url: '/pages/handhousing/authentication'
				},
				{
					img: 'https://neidangjia.oss-accelerate.aliyuncs.com/handhousing/img2.png',
					imgOn: 'https://neidangjia.oss-accelerate.aliyuncs.com/handhousing/img2_on.png',
					name: '免责声明协议',
					type: '签署协议',
					typeOn: '已签署协议'
				}
			],
			renzheng: false,
			label: {
				checked: false,
				name: '本人已却读完上述条款，并确认按合同履行相关事务'
			},
			queren: false,
			type: '',
			reality_name: ''
		};
	},
	async onLoad(e) {
		// #ifdef MP-WEIXIN
		uni.hideShareMenu();
		// #endif
		if (e.type) {
			this.type = +e.type;
		}
		await this.getxie();
	},
	onShow() {
		this.renzheng = uni.getStorageSync('renzheng_ids');
		if (this.renzheng) {
			this.reality_name = JSON.parse(this.renzheng).Name;
		}
	},
	onHide() {
		uni.removeStorageSync('renzheng_ids')
	},
	methods: {
		async getxie() {
			let getXieyi = this.type === 1 ? 'getData' : 'gettowhousecontractdata';
			let res = await this.require(getXieyi);
			if (res) {
				this.xieyi = res;
			}
		},
		async getclick() {
			this.show = false;
			this.queren = true;
		},
		checkboxChange(n) {
			var values = n.detail.value;
			if (values.includes(this.label.name)) {
				this.label.checked = true;
			} else {
				this.label.checked = false;
				this.queren = false;
			}
		},
		getdianji() {
			if (!this.renzheng) {
				return this.$u.toast('请先进行认证');
			} else {
				this.show = true;
			}
		},
		sumit() {
			if (!this.renzheng) {
				return this.$u.toast('请先进行认证');
			}
			if (!this.queren) {
				return this.$u.toast('请签署免责声明协议');
			}
			uni.setStorageSync('fangchanzheng',JSON.stringify(this.renzheng));
			if (this.type === 1) {
				this.nextNav('/pages/zufang/shangchuan?item=' + this.renzheng + '&type=' + this.type);
			} else {
				this.nextNav('/pages/mine/shangchuan?item=' + this.renzheng);
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.boxlv {
	background-color: #0e5642;
	height: 80rpx;
}

.clv {
	color: #0e5642;
}

.widtext{
	text-align: center;
}

.boxding {
	overflow-y: auto;
	height: 90vh;
}

.boxque {
	width: 244rpx;
	height: 60rpx;
	line-height: 60rpx;
	text-align: center;
	color: #fff;
	background-color: #bfbfbf;
	border-radius: 10rpx;
}

.boxquelv {
	background-color: #0e5642;
}

.boxali {
	align-items: center;
}

.cdb {
	color: #dbb07b;
	font-size: 24rpx;
}

.c5a {
	color: #5a5a5a;
}

.boxbutt {
	width: 352rpx;
	height: 70rpx;
	line-height: 70rpx;
	text-align: center;
	color: #fff;
	background-color: #0e5543;
	border-radius: 10rpx;
}

.boxtop {
	left: 30rpx;
	right: 30rpx;
	bottom: 0;
}
</style>
